package com.mioto.ld.module.feedback.service.impl;

import com.mioto.ld.module.feedback.dao.FeedbackDao;
import com.mioto.ld.module.feedback.model.Feedback;
import com.mioto.ld.module.feedback.model.FeedbackStatus;
import org.springframework.stereotype.Service;

import com.mioto.ld.module.feedback.dao.FeedbackReplyDao;
import com.mioto.ld.module.feedback.model.FeedbackReply;
import com.mioto.ld.module.feedback.service.IFeedbackReplyService;
import org.springframework.transaction.annotation.Transactional;

import javax.annotation.Resource;
import java.util.List;

/**
 *
 * @author mioto
 * @date 2024-05-14 14:54:43
 */
@Service("feedbackReplyService")
public class FeedbackReplyServiceImpl implements IFeedbackReplyService{

    @Resource
    private FeedbackReplyDao feedbackReplyDao;
    @Resource
    private FeedbackDao feedbackDao;

    @Override
    public List<FeedbackReply> findList(FeedbackReply feedbackReply) {
        return feedbackReplyDao.findList(feedbackReply);
    }

    @Override
    @Transactional(rollbackFor = Exception.class)
    public int insert(FeedbackReply feedbackReply) {
        Feedback feedback = new Feedback();
        feedback.setId(feedbackReply.getFeedbackId());
        feedback.setStatus(FeedbackStatus.FEEDBACK_STATUS_REPLIED);
        feedbackDao.updateIgnoreNull(feedback);
        feedbackReply.initCreateData();
        return feedbackReplyDao.insertIgnoreNull(feedbackReply);
    }

    @Override
    public int update(FeedbackReply feedbackReply) {
        return feedbackReplyDao.update(feedbackReply);
    }

    @Override
    public int updateIgnoreNull(FeedbackReply feedbackReply) {
        return feedbackReplyDao.updateIgnoreNull(feedbackReply);
    }

    @Override
    public FeedbackReply findByColumn(String column, Object value) {
        return feedbackReplyDao.findByColumn(column,value);
    }

    @Override
    public int deleteByColumn(String column, Object value) {
        return feedbackReplyDao.deleteByColumn(column,value);
    }

    @Override
    public int batchDelete(Integer[] ids) {
        return feedbackReplyDao.batchDelete(ids);
    }
}